from django.db import models



class Department(models.Model):
    """
    部门
    """
    name = models.CharField(max_length=30)

    class Meta:
        db_table = 'tb_department'

    def __str__(self):
        return self.name


class Duty(models.Model):
    """
    职务
    """
    name = models.CharField(max_length=30, verbose_name='职务名称')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'tb_duty'


class Staff(models.Model):  # 不能也继承BaseModel，会冲突
    """
    员工
    """
    SEX_CHOICE = (
        (1, '男'),
        (2, '女')
    )
    department = models.ForeignKey(Department, on_delete=models.CASCADE)
    duty = models.ForeignKey(Duty, on_delete=models.CASCADE)
    name = models.CharField(max_length=30, verbose_name='姓名')
    sex = models.IntegerField(choices=SEX_CHOICE, default=1, verbose_name='性别')
    phone = models.CharField(max_length=11, verbose_name='手机号')
    email = models.EmailField(max_length=60, verbose_name='邮箱')
    census_register = models.CharField(max_length=200, verbose_name='户籍')

    # picture = models.ImageField(upload_to='staff_pic', verbose_name='员工照片')

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'tb_staff'